#include "send_fr.h"

void send_rf(unsigned long codage)
{
  // detachInterrupt(0);

  Serial.print("transmit");
  Serial.println(codage);
  transmit(1,31);
  for (int j=0;j<=20;j++)
  {
    for (int i = 23 ; i>=0 ; i--)
    {
      byte tmp = (codage >> i) & 1 ;
      if (tmp ==0) //T0
      {
        transmit(1,3);
      }
      else
      {
        transmit(3,1);
      }
    }
    transmit(1,31);
  }
  //attachInterrupt(0, interruptHandler, CHANGE);
  
}


void transmit(int nHighPulses, int nLowPulses)
{
  digitalWrite(def_broche_RF_T, HIGH);
  delayMicroseconds( 316 * nHighPulses);
  digitalWrite(def_broche_RF_T, LOW);
  delayMicroseconds( 316 * nLowPulses);
}


